package com.sevencar.activity;

import com.example.lightble.CmdSend;
import com.example.lightble.R;

import me.maxwin.view.XListView.IXListViewListener;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class CommentManageFragment extends Fragment implements IXListViewListener {

	private Activity mActivity;
	private TextView mTitleTv;
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		this.mActivity = activity;
	}

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		
		return inflater.inflate(R.layout.fragment_comment, container, false);
	}
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		
	}
	
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		initViews(view);
	}
	private void initViews(View view) {
		RelativeLayout rl_jingx = (RelativeLayout)view.findViewById(R.id.re_jingx);
		rl_jingx.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(),ColorBoardActivity.class);
				startActivity(intent);
			}
		});
		RelativeLayout rl_sepad = (RelativeLayout)view.findViewById(R.id.re_sepad);
		rl_sepad.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(),ColorPadActivity.class);
				startActivity(intent);
			}
		});
		
		RelativeLayout re_card_bag =(RelativeLayout)getView().findViewById(R.id.re_card_bag);
		re_card_bag.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
//					currentColor=0xFFFFFF;
					SharedPreferences sp = getActivity().getSharedPreferences("color", 0);
					Editor ed = sp.edit();
					ed.putInt("currentcolor", 0xffffff);
					ed.commit();
					
//					mColorBar.setColor(currentColor);
//					colorPicker.setColor(currentColor);
//					mlayout.setBackgroundColor(currentColor);
//					CmdSend mCmdSend=;
					
					byte[] test=CmdSend.getInstance().getOneKeyWhiteArray();
					HomeFragment.mBLEServiceInstance.sendData(test); 
			    	Toast.makeText(getActivity(), "发送一键白光数据包", Toast.LENGTH_SHORT).show();
				}
			});
		
	}
	
	@Override
	public void onRefresh() {
		
	}

	@Override
	public void onLoadMore() {
		
	}

}
